<?php
declare(strict_types=1);
namespace Service\CommodityService;

use App\Model\CommodityModel\SupplierCommodityCustomInfo;
use Service\AppService\IdService;
use Service\BaseService;
use Service\Code\Normal;
use Service\CommodityAttributeService\CustomCountryInfoService;
use Service\CommodityAttributeService\CustomCurrencyService;
use Service\CommodityAttributeService\CustomUnitInfoService;

class CommodityCustomInfoService extends BaseService
{
    /**
     * 新增备案信息
     * @param $customInfo
     * @return array
     */
    public function insertConsumerCustomInfo($customInfo):array
    {
        $customData = [
            'ID'=> IdService::instance()->getOtherID(),
            'Country' => $customInfo['Country'],
            'CountryCode' => CustomCountryInfoService::instance()->getCustomId($customInfo['Country']),
            'Currency' => $customInfo['Currency'],
            'CurrencyCode' => CustomCurrencyService::instance()->getCustomId($customInfo['Currency']),
            'MeasurementUnit' => $customInfo['MeasurementUnit'],
            'MeasurementUnitCode' => CustomUnitInfoService::instance()->getCustomId($customInfo['MeasurementUnit']),
            'DeclareBarCode' => $customInfo['DeclareBarCode'],
            'Specifications' => $customInfo['Specifications'],
            'DeclareSKUCode' => $customInfo['DeclareSKUCode'],
            'DeclareCommodityName' => $customInfo['DeclareCommodityName'],
            'SupplierCommodityID'=>$customInfo['ID'],
            'Function'=>$customInfo['Function']??'',
            'CreateTime'=>date('Y-m-d H:i:s'),
            'UpdateTime'=>date('Y-m-d H:i:s'),
        ];
        SupplierCommodityCustomInfo::instance()->insert($customData);
        return Normal::returnCode(
            Normal::SUC,
            '添加成功'
        );
    }

}